Source Code Viewer - Example 6 - ViewGamePicturePopupAction

package name.matthewgreet.example6.action;

import javax.servlet.http.HttpSession;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.opensymphony.xwork2.ActionSupport;

import name.matthewgreet.example6.dto.GameDTO;
import name.matthewgreet.example6.util.GameCompositeCache;
import name.matthewgreet.example6.view.GameDetailDisplay;
import name.matthewgreet.strutscommons.action.AbstractViewActionSupport;
import name.matthewgreet.strutscommons.util.ListCache;
import name.matthewgreet.strutscommons.util.NA;


/**
 * Displays game picture in a popup.  
 */
@InterceptorRef("ViewStack")
@Results({
	@Result(name=ActionSupport.SUCCESS, location="/pages/GamePicturePopup.jsp")
})
public class ViewGamePicturePopupAction extends AbstractViewActionSupport {
	private static final long serialVersionUID = -5403446798586134258L;
	
	private GameDetailDisplay gameDisplay;
	private String imageURL;
	
	
    @Action("/ViewGamePicturePopup")
    @Override
    public String execute() throws Exception {
    	ListCache<NA,Integer,GameDTO> masterListCache;
    	ListCache<NA,Integer,GameDTO> listCache;
    	HttpSession session;
    	
    	session = getBrowserTabSession();
    	masterListCache = GameCompositeCache.getInstance(session).getMasterListCache();
    	gameDisplay = new GameDetailDisplay(masterListCache);
	    gameDisplay.setBrowserTabSessionData(getBrowserTabSession(), GameCompositeCache.class, getTabId());
    	gameDisplay.init();
	    
    	listCache = GameCompositeCache.getInstance(session).getMasterListCache();
	    
	    if (listCache.getSelected() != null) {
	    	imageURL = listCache.getSelected().getImageURL();
	    } else {
	    	imageURL = "";
	    }
		
	    
		return SUCCESS;
    }

	public GameDetailDisplay getGameDisplay() {
		return gameDisplay;
	}

	public String getImageURL() {
		return imageURL;
	}


}